package com.didispace;

import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.netflix.eureka.resources.StatusResource;
import com.netflix.eureka.util.StatusInfo;

@RestController("/status")
public class StatusController {

	@RequestMapping(value = "/getstatus",method = RequestMethod.GET)
	public String getStatus(){
		StatusInfo statusInfo;
		try {
			statusInfo = new StatusResource().getStatusInfo();
		}
		catch (Exception e) {
			statusInfo = StatusInfo.Builder.newBuilder().isHealthy(false).build();
		}
		System.out.println(statusInfo.getApplicationStats());
		System.out.println(statusInfo.getGeneralStats());
		System.out.println(statusInfo.getInstanceInfo().toString());
		return statusInfo.toString();
		
	}
}
